<MudStack>
    <MudChipSet T="string"
                SelectionMode="@SelectionMode.MultiSelection"
                AllClosable="@AreChipsClosable"
                Disabled="@Disabled"
                ReadOnly="@ReadOnly"
                @bind-SelectedValues="@_selectedValues"
                OnClose="@OnClose">
        @for (var i = 0; i < _chips.Count; i++)
        {
            var localIndex = i;
            <MudChip id=@($"chip-{localIndex + 1}")
                     T="string"
                     Text="@_chips[localIndex]"
                     Color="Color.Primary" />
        }
    </MudChipSet>
    <MudButton id="add-chip-button"
               StartIcon="@Icons.Material.Filled.Add"
               OnClick="@AddChip">
        Add chip
    </MudButton>
    <MudText>Chips: @_chips.Count | Selected: @_selectedValues.Count</MudText>
</MudStack>

@code {
    private readonly List<string> _chips = [];
    private IReadOnlyCollection<string> _selectedValues = [];

    [Parameter]
    public bool AreChipsClosable { get; set; }

    [Parameter]
    public bool Disabled { get; set; }

    [Parameter]
    public bool ReadOnly { get; set; }

    [Parameter]
    public EventCallback<MudChip<string>> OnClose { get; set; }

    private void AddChip() => _chips.Add($"Chip {_chips.Count + 1}");
}